<template>
  <div class="wrap-ward">
    <div class="wrad-head">
      <img src="../../img/wardR/Return.png" alt="加载中" class="wrad-back" @click="Goback">
      <span class="wrad-title">患者信息</span>
    </div>
    <div class="tab-card">
      <div class="option-card">
        <span
          class="tab-tit"
          @click="handleTab(index)"
          v-for="(item, index) in items"
          :key="index"
          :class="{active:index===actived}"
        >{{item.tab}}</span>
      </div>
      <div class="tab-content">
        <div class="tab-wrapbox clearboth">
          <div class="tab-page" v-for="(item, index) in items" :key="index">
            <!-- keep-alive 具名插槽 -->
            <keep-alive>
              <component :is="item.tabComponent"></component>
            </keep-alive>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
// eslint语法
import Basic from './Basic'
export default {
  name: 'InforM',
  components: {
    Basic
  },
  data () {
    return {
      actived: 0,
      items: [
        {
          tab: '基本信息',
          tabComponent: `Basic`
        }
      ]
    }
  },
  methods: {
    handleTab (index) {
      this.actived = index
      document.querySelector(
        '.wrap-ward .tab-card .tab-wrapbox'
      ).style.webkitTransform = 'translateX(-' + this.actived * 20 + '%)'
    },
    Goback () {
      this.$router.go(-1)
    }
  }
}
</script>

<style lang="stylus" scoped>
@import '../../assets/css/variables.styl';

.wrap-ward {
  backgorund-color: #f7f8fa;
  width: 100%;
  height: auto;

  .wrad-head {
    display: flex;
    align-items: center;
    padding: 0 0.35rem;
    background-color: $bgColor;
    height: 0.9rem;
  }

  .wrad-back {
    height: 0.3rem;
    padding-right: 0.18rem;
  }
}

.wrap-ward .wrad-title {
  font-size: 0.36rem;
  color: $fontColor;
}

.wrap-ward .tab-card {
  padding: 0 0.3rem;
}

.wrap-ward .tab-card .option-card {
  display: flex;
  height: 0.86rem;
  line-height: 0.9rem;
  font-size: 0.28rem;
  border-bottom: 1px solid #e8e9ee;
  padding: 0 0.3rem;
}

.wrap-ward .tab-card .option-card .tab-tit {
  display: inline-block;
  // width: 1.75rem;
  text-align: center;
}

.wrap-ward .tab-card .option-card .active {
  border-bottom: 2px solid #27ae9e;
  color: #27ae9e;
}

.wrap-ward .tab-card .tab-content {
  width: 100%;
  overflow: hidden;
}

.wrap-ward .tab-card .tab-wrapbox {
  width: 100%;
  transition: all 200ms;
}

.wrap-ward .tab-card .clearboth::after {
  content: '';
  display: inline-block;
  clear: both;
}

.wrap-ward .tab-card .tab-page {
  float: left;
  width: 100%;
  // height: 10rem;
  // line-height: 10rem;
  // text-align: center;
  // background-color: #eee;
}
</style>
